#ifndef __COMPUTURE_MGR_H__
#define __COMPUTURE_MGR_H__

#include "NetDef.h"
#include "Protocal/Common.pb.h"

struct xMSG;

class CSrvComputure : public xObjBase
{
public:
	CSrvComputure();
	virtual ~CSrvComputure();

	void SendMsg2Server(xMSG& msg);
	virtual void onUnBind();

	DECLARE_VAR(ENetDef::_eNet, m_eSrvType);
	DECLARE_VAR(U32, m_nSrvIndex);
	DECLARE_VAR(std::string, m_strIPPort);
	DECLARE_VAR(U32, m_nPlayers);
protected:
};

class CAsioTcpLink;
class CAsioTcpClient;

typedef std::vector<CSrvComputure*>	SrvList;

class CComputureMgr
{
	SINGLETON_CLASS(CComputureMgr);
public:
	void getTypeSrvList(ENetDef::_eNet et, SrvList& list);
	CSrvComputure* getLightServer(ENetDef::_eNet et);
	CSrvComputure* getServer(const std::string& ip_port);
	void AddServer(CAsioTcpLink* pClient, MYTH::SrvReg* pReg = NULL);
	void ClearServer(std::string ip_port);
	void ClearServer(U64 uGuid);

	void GetAllSrvs(MYTH::SrvReg_R& r);
	void SendMsg2AllServer(xMSG& msg);
	void SendMsg2Server(std::string& ip_port, xMSG& msg);
	void SendMsg2Server(ENetDef::_eNet et, xMSG& msg);
protected:
	boost::unordered_map<std::string, xObjBase*>	m_mapComputureMgr;
};

#endif //__COMPUTURE_MGR_H__